package com.kzw.core.bean;

/**
 * code: msg: data: success
 */
public class Msg {

	private boolean success = true;
	// 错误消息
	private String msg;
	// 错误码：0（正常）
	private int code;
	// 成功时的数据
	private Object data;
	// 数据量
	private Integer count;

	public Msg() {
	}

	public Msg(boolean success) {
		this.success = success;
	}

	public Msg(boolean success, int code) {
		this.success = success;
		this.code = code;
	}

	public Msg(boolean success, int code, String msg) {
		this.success = success;
		this.code = code;
		this.msg = msg;
	}

	public Msg(boolean success, int code, String msg, Object data) {
		this.success = success;
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static Msg success(String message) {
		Msg r = new Msg();
		r.setSuccess(true);
		r.setCode(200);
		r.setMsg(message);
		r.setData(message);
		return r;
	}

	public static Msg success(String msg, Object obj) {
		Msg r = new Msg();
		r.setSuccess(true);
		r.setCode(200);
		r.setMsg(msg);
		r.setData(obj);
		return r;
	}

	public static Msg error(String message) {
		Msg r = new Msg();
		r.setSuccess(false);
		r.setCode(500);
		r.setMsg(message);
		return r;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

}
